package customer;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.*;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.*;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.4.0)",
    comments = "Source: customer.proto")
public final class CustomerGrpc {

  private CustomerGrpc() {}

  public static final String SERVICE_NAME = "customer.Customer";

  // Static method descriptors that strictly reflect the proto.
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static final io.grpc.MethodDescriptor<CustomerOuterClass.CustomerFilter,
      CustomerOuterClass.CustomerRequest> METHOD_GET_CUSTOMERS =
      io.grpc.MethodDescriptor.<CustomerOuterClass.CustomerFilter, CustomerOuterClass.CustomerRequest>newBuilder()
          .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
          .setFullMethodName(generateFullMethodName(
              "customer.Customer", "GetCustomers"))
          .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              CustomerOuterClass.CustomerFilter.getDefaultInstance()))
          .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              CustomerOuterClass.CustomerRequest.getDefaultInstance()))
          .build();
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static final io.grpc.MethodDescriptor<CustomerOuterClass.CustomerRequest,
      CustomerOuterClass.CustomerResponse> METHOD_CREATE_CUSTOMER =
      io.grpc.MethodDescriptor.<CustomerOuterClass.CustomerRequest, CustomerOuterClass.CustomerResponse>newBuilder()
          .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
          .setFullMethodName(generateFullMethodName(
              "customer.Customer", "CreateCustomer"))
          .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              CustomerOuterClass.CustomerRequest.getDefaultInstance()))
          .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              CustomerOuterClass.CustomerResponse.getDefaultInstance()))
          .build();

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static CustomerStub newStub(io.grpc.Channel channel) {
    return new CustomerStub(channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static CustomerBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    return new CustomerBlockingStub(channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static CustomerFutureStub newFutureStub(
      io.grpc.Channel channel) {
    return new CustomerFutureStub(channel);
  }

  /**
   */
  public static abstract class CustomerImplBase implements io.grpc.BindableService {

    /**
     */
    public void getCustomers(CustomerOuterClass.CustomerFilter request,
                             io.grpc.stub.StreamObserver<CustomerOuterClass.CustomerRequest> responseObserver) {
      asyncUnimplementedUnaryCall(METHOD_GET_CUSTOMERS, responseObserver);
    }

    /**
     */
    public void createCustomer(CustomerOuterClass.CustomerRequest request,
                               io.grpc.stub.StreamObserver<CustomerOuterClass.CustomerResponse> responseObserver) {
      asyncUnimplementedUnaryCall(METHOD_CREATE_CUSTOMER, responseObserver);
    }

    @Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            METHOD_GET_CUSTOMERS,
            asyncServerStreamingCall(
              new MethodHandlers<
                CustomerOuterClass.CustomerFilter,
                CustomerOuterClass.CustomerRequest>(
                  this, METHODID_GET_CUSTOMERS)))
          .addMethod(
            METHOD_CREATE_CUSTOMER,
            asyncUnaryCall(
              new MethodHandlers<
                CustomerOuterClass.CustomerRequest,
                CustomerOuterClass.CustomerResponse>(
                  this, METHODID_CREATE_CUSTOMER)))
          .build();
    }
  }

  /**
   */
  public static final class CustomerStub extends io.grpc.stub.AbstractStub<CustomerStub> {
    private CustomerStub(io.grpc.Channel channel) {
      super(channel);
    }

    private CustomerStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected CustomerStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new CustomerStub(channel, callOptions);
    }

    /**
     */
    public void getCustomers(CustomerOuterClass.CustomerFilter request,
                             io.grpc.stub.StreamObserver<CustomerOuterClass.CustomerRequest> responseObserver) {
      asyncServerStreamingCall(
          getChannel().newCall(METHOD_GET_CUSTOMERS, getCallOptions()), request, responseObserver);
    }

    /**
     */
    public void createCustomer(CustomerOuterClass.CustomerRequest request,
                               io.grpc.stub.StreamObserver<CustomerOuterClass.CustomerResponse> responseObserver) {
      asyncUnaryCall(
          getChannel().newCall(METHOD_CREATE_CUSTOMER, getCallOptions()), request, responseObserver);
    }
  }

  /**
   */
  public static final class CustomerBlockingStub extends io.grpc.stub.AbstractStub<CustomerBlockingStub> {
    private CustomerBlockingStub(io.grpc.Channel channel) {
      super(channel);
    }

    private CustomerBlockingStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected CustomerBlockingStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new CustomerBlockingStub(channel, callOptions);
    }

    /**
     */
    public java.util.Iterator<CustomerOuterClass.CustomerRequest> getCustomers(
        CustomerOuterClass.CustomerFilter request) {
      return blockingServerStreamingCall(
          getChannel(), METHOD_GET_CUSTOMERS, getCallOptions(), request);
    }

    /**
     */
    public CustomerOuterClass.CustomerResponse createCustomer(CustomerOuterClass.CustomerRequest request) {
      return blockingUnaryCall(
          getChannel(), METHOD_CREATE_CUSTOMER, getCallOptions(), request);
    }
  }

  /**
   */
  public static final class CustomerFutureStub extends io.grpc.stub.AbstractStub<CustomerFutureStub> {
    private CustomerFutureStub(io.grpc.Channel channel) {
      super(channel);
    }

    private CustomerFutureStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected CustomerFutureStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new CustomerFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<CustomerOuterClass.CustomerResponse> createCustomer(
        CustomerOuterClass.CustomerRequest request) {
      return futureUnaryCall(
          getChannel().newCall(METHOD_CREATE_CUSTOMER, getCallOptions()), request);
    }
  }

  private static final int METHODID_GET_CUSTOMERS = 0;
  private static final int METHODID_CREATE_CUSTOMER = 1;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final CustomerImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(CustomerImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_GET_CUSTOMERS:
          serviceImpl.getCustomers((CustomerOuterClass.CustomerFilter) request,
              (io.grpc.stub.StreamObserver<CustomerOuterClass.CustomerRequest>) responseObserver);
          break;
        case METHODID_CREATE_CUSTOMER:
          serviceImpl.createCustomer((CustomerOuterClass.CustomerRequest) request,
              (io.grpc.stub.StreamObserver<CustomerOuterClass.CustomerResponse>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @Override
    @SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  private static final class CustomerDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
    @Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return CustomerOuterClass.getDescriptor();
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (CustomerGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new CustomerDescriptorSupplier())
              .addMethod(METHOD_GET_CUSTOMERS)
              .addMethod(METHOD_CREATE_CUSTOMER)
              .build();
        }
      }
    }
    return result;
  }
}
